<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        .welcome{display: none;}
    </style>
</head>
<body>
    <h2>这是首页</h2>

    <div class="top">
        <div class="welcome">
            欢迎 <a href="./user.html">xxx</a> 登录，<em>退出</em>
        </div>
        <div class="login">
            <a href="./login.html">登录</a>
            <a href="./register.html">注册</a>
        </div>
    </div>
</body>
<script type="module">
    
    import $ from "./modules/select.js";
    import guard from "./modules/guard.js";
    // 首页的登录守卫
    guard();
    
    // 首页的其他功能
    // 退出功能
    $(".welcome em").onclick = function(){
        localStorage.removeItem("userMsg");

        $(".welcome").style.display = "none";
        $(".login").style.display = "block";
    }
    // ....

    
</script>
</html>